package cn.iocoder.yudao.module.shop.info.vo;

import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.business.eligibility.pojo.form.EligibilityApplySaveDTO;
import cn.iocoder.yudao.framework.region.vo.getter.AddressSaveGetter;
import cn.iocoder.yudao.framework.validation.CitizenIdCard;
import cn.iocoder.yudao.framework.validation.CreditCode;
import cn.iocoder.yudao.framework.validation.ImageUrl;
import cn.iocoder.yudao.framework.validation.groups.UpdateGroup;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

@Schema(description = "店铺信息新增 Request VO")
@Data
public class AppShopInfoSaveDTO extends EligibilityApplySaveDTO implements AddressSaveGetter {

    @Schema(description = "唯一编号，更新时不能为空", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1")
    @NotNull(message = "唯一编号不能为空", groups = {UpdateGroup.class})
    private Long id;

    @Schema(description = "个人姓名或企业名称", example = "羡民演示店")
    private String name;

    @SuppressWarnings("unused")
    @AssertTrue(message = "个人姓名或企业名称不能为空")
    public boolean validName() {
        return StrUtil.isNotBlank(name);
    }

    @Schema(description = "徽标", example = "https://www.example.com/logo.png")
    private String logo;

    @Schema(description = "门头照", example = "https://www.example.com/banner.png")
    private String banner;

    @Schema(description = "简介", example = "用于演示店铺功能")
    private String introduction;

    @Schema(description = "主营类目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "主营类目编号不能为空")
    private Long categoryId;

    @Schema(description = "身份证号码", example = "522426199*1104****")
    @CitizenIdCard
    private String ownerEidNo;

    @SuppressWarnings("unused")
    @AssertTrue(message = "身份证号码不能为空")
    public boolean validCitizenIdCardNo() {
        return StrUtil.isNotBlank(ownerEidNo);
    }

    @Schema(description = "身份证正面图片地址", example = "https://www.example.com/xxx.jpg")
    @ImageUrl
    private String ownerEidFrontUrl;

    @Schema(description = "身份证反面图片地址", example = "https://www.example.com/yyy.jpg")
    @ImageUrl
    private String ownerEidBackUrl;

    @SuppressWarnings("unused")
    @AssertTrue(message = "身份证照片不能为空")
    public boolean validCitizenIdCardImage() {
        return StrUtil.isNotBlank(ownerEidFrontUrl) && StrUtil.isNotBlank(ownerEidBackUrl);
    }

    @Schema(description = "营业执照号码", example = "5201314OOOO")
    @CreditCode
    private String businessLicenseNo;

    @SuppressWarnings("unused")
    @AssertTrue(message = "营业执照号码不能为空")
    public boolean validBusinessLicenseNo() {
        return true;
    }

    @Schema(description = "营业执照图片地址", example = "https://www.example.com/zzz.jpg")
    @ImageUrl
    private String businessLicenseUrl;

    @SuppressWarnings("unused")
    @AssertTrue(message = "营业执照图片不能为空")
    public boolean validBusinessLicenseImage() {
        return StrUtil.isNotBlank(businessLicenseUrl);
    }

    @Schema(description = "区县编码", example = "520102")
    @Pattern(regexp = "\\d{6}", message = "区县编码格式错误")
    private String countyCode;

    @SuppressWarnings("unused")
    @AssertTrue(message = "区县编码不能为空")
    public boolean validCountyCode() {
        return StrUtil.isNotBlank(countyCode);
    }

    @Schema(description = "详细地址", example = "花果园金融街5号驰通集团公司")
    private String detailAddress;

    @SuppressWarnings("unused")
    @AssertTrue(message = "详细地址不能为空")
    public boolean validDetailAddress() {
        return StrUtil.isNotBlank(detailAddress);
    }

    @Schema(description = "纬度", example = "26.567322")
    private Double latitude;

    @Schema(description = "经度", example = "106.690801")
    private Double longitude;

    @Schema(description = "招商人员编号，通过扫招商人员的商家推广码获得", example = "1")
    private Long agencyId;

}
